<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/css/plat-style.css" media="all">
</head>
<body>

<div class="layui-container">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" id="classifyAddForm">
                <input type="hidden" name="id" value="${id}">
                <input type="hidden" name="firstId" value="${third.firstId}">
                <input type="hidden" name="secondId" value="${third.secondId}">
                <input type="hidden" name="level" id="level" value="${level}">
                <input type="hidden" name="editType" id="editType" value="${editType}">
                <div class="layui-form-item" id="firstC">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>一级分类</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" value="${third.fName}">
                    </div>
                </div>
                <div class="layui-form-item" id="secondC">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>二级分类</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" value="${third.sName}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>分类名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" class="layui-input" value="${third.name}">
                        <span class="green">格式：长度不能超过10位(不可输入特殊字符)</span>
                    </div>
                </div>
                <!-- 三级分类不需要图标 -->
                <c:if test="${!(level == 3 || (level == 2 && editType==1))}">
	                <div class="layui-form-item">
	                    <label class="layui-form-label"><span class="red">*&nbsp;</span>分类图片</label>
	                    <div class="layui-input-block">
	                        <label for="imgUrl" class="layui-btn layui-btn-sm layui-btn-primary">上传图片</label>
	                        <input accept=".jpg,.png,.gif,.jpeg" type="file" style="display:none;" name="imgUrl" id="imgUrl"
	                               onchange="showImg(this)"/>
	                        <img id="imgf" src="${third.url}" style="width: 100px;height: 100px;" /><br>
	                        <span class="green">注：建议上传大小比例（一级/二级：496:164|三级:152:152）,格式支持jpg，png等</span>
	                    </div>
	                </div>
                </c:if>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="sort" autocomplete="off" class="layui-input" value="${third.sort}">
                        <span class="green">注：排序越高越靠前, (格式为:数字0-9，不能包含其他字符)</span>
                    </div>
                </div>
            </form>
            <div class="layui-form-item layui-layout-admin">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0;">
                        <button class="layui-btn" onclick="FormSubmit('#classifyAddForm','/classify/editClassify')">保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/plugins/image/previewImg.js"></script>
<script>
    layui.config({
        //静态资源所在路径
        base: '/layuiadmin/'
    }).extend({
        //主入口模块
        index: 'lib/index'
    }).use(['index', 'form'], function(){
        var $ = layui.$,layer = layui.layer,element = layui.element;
    });

    $(function () {
        // type=1 新增； type=2 编辑
        var type = $("#editType").val();
        var level = $("#level").val();
        // 一级分类 新增
        if(level==1){
            $("#secondC").hide();
            if(type==1){
                $("#firstC").find('input').attr('readonly','readonly');
            }else if(type==2){
                $("#firstC").hide();
            }
        }else if(level==2){
            if(type==1){
                $("#firstC").find('input').attr('readonly','readonly');
                $("#secondC").find('input').attr('readonly','readonly');
            }else if(type==2){
                $("#secondC").hide();
                $("#firstC").find('input').attr('readonly','readonly');
            }
        }else if(level==3){
            $("#firstC").find('input').attr('readonly','readonly');
            $("#secondC").find('input').attr('readonly','readonly');
        }
        if (level==0 && type==0){
            $("#firstC").hide();
            $("#secondC").hide();
        }
    });
</script>
</body>
</html>